<?php
/**
 * Created by Zhy
 * User: Zhy
 * Date: 2019/1/19
 * Time: 10:47
 */

namespace app\mec\controller;


use think\Db;

class Consumer extends Base
{
    /*****
     * @return mixed
     * 查看详情
     */
    public function detail(){
        $id = input('param.id');
        $user_week_money = Db::table('up_u_user')->order('user_week_money desc')->column('user_id');
        $user_month_money = Db::table('up_u_user')->order('user_month_money desc')->column('user_id');
        $info =Db::name('u_user')->alias('a')
            ->join('up_area ua1', 'ua1.district_id = user_province', 'left')
            ->join('up_area ua2', 'ua2.district_id = user_city', 'left')
            ->join('up_area ua3', 'ua3.district_id = user_district', 'left')
            ->where('user_id',$id)
            ->field('a.*,ua1.district as sheng, ua2.district as shi, ua3.district as qu')
            ->find();
        if(!$info){
            echo '此用户已不存在！';
            exit;
        }
        $pm_week = array_search($info['user_id'],$user_week_money)+1;
        $pm_month = array_search($info['user_id'],$user_month_money)+1;
        if($info['user_wx_token']!=''){
            $info['wx_status'] = "已绑定";
        }else{
            $info['wx_status'] = "未绑定";
        }
        if($info['user_qq_token']!=''){
            $info['qq_status'] = "已绑定";
        }else{
            $info['qq_status'] = "未绑定";
        }
        if($info['user_wb_token']!=''){
            $info['wb_status'] = "已绑定";
        }else{
            $info['wb_status'] = "未绑定";
        }
        if($info['user_zfb_token']!=''){
            $info['zfb_status'] = "已绑定";
        }else{
            $info['zfb_status'] = "未绑定";
        }
//        if(!session('?admin_user_id')){
//            session('admin_user_id',input('id'));
//        }
        if($info['user_gender']==1){
            $info['sex']= '男';
        }else{
            $info['sex']= '女';
        }
        if($info['user_face']==1){
            $info['face']= '未认证';
        }else{
            $info['face']= '已认证';
        }
        unset($info['user_phone']);
        $info['address']  = $info['sheng'].$info['shi'].$info['qu'];
        $info['pm_week']  = $pm_week;
        $info['pm_month']  = $pm_month;
        $this->assign('res',$info);
        return $this->fetch();
    }
}